home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00025_Rollover Anim Button Class.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  5.8 KB  |  219 lines

  1. property status, animChannel, introFrames, mainFrames, outroFrames, staticCastPos, castOffset, buttonChannel, commandString, clicked, clickSound, ROsound, resetFlag, soundStatus, soundWait
  2. global gRollAnimButton, gActorList, gSceneObject, gSimObject, gVTLobject, gVTLgameObject, g3DObject, gQTViewerObject, gAwardsObject, gHardHatObject, gAlbumObject, gLoopGroupObject, gCustomCursor
  3.  
  4. on birth me, command, buttonChannelNum, animChannelNum, main, soundA, soundB, intro, outro
  5.   set status to #static
  6.   set clicked to 0
  7.   set soundWait to 1
  8.   set mainFrames to main
  9.   set soundStatus to #off
  10.   set clickSound to soundA
  11.   set ROsound to soundB
  12.   if voidp(intro) then
  13.     set introFrames to 0
  14.   else
  15.     set introFrames to intro
  16.   end if
  17.   if voidp(outro) then
  18.     set outroFrames to 0
  19.   else
  20.     set outroFrames to outro
  21.   end if
  22.   set animChannel to animChannelNum
  23.   set buttonChannel to buttonChannelNum
  24.   set staticCastPos to the castNum of sprite animChannel
  25.   set castOffset to 0
  26.   set commandString to command
  27.   set resetFlag to 1
  28.   preLoadCast(staticCastPos + 1, staticCastPos + introFrames + mainFrames + outroFrames)
  29.   return me
  30. end
  31.  
  32. on update me
  33.   if status = #static then
  34.     if rollOver(buttonChannel) and not soundBusy(1) then
  35.       hideCustomCursor(me)
  36.       set gRollAnimButton to me
  37.       hideOtherActors(gRollAnimButton)
  38.       puppetSprite(animChannel, 1)
  39.       if ROsound <> EMPTY then
  40.         puppetSound(ROsound)
  41.         set soundStatus to #ROsoundOn
  42.       end if
  43.       if introFrames = 0 then
  44.         set status to #main
  45.       else
  46.         set status to #intro
  47.       end if
  48.       set castOffset to 1
  49.       replaceBitmap(me)
  50.     else
  51.       exit
  52.     end if
  53.   else
  54.     if status = #intro then
  55.       processSound(me)
  56.       set castOffset to castOffset + 1
  57.       if castOffset > introFrames then
  58.         set status to #main
  59.       end if
  60.       replaceBitmap(me)
  61.     else
  62.       if status = #main then
  63.         processSound(me)
  64.         if castOffset = (introFrames + mainFrames) then
  65.           if not clicked and (rollOver(buttonChannel) = 1) then
  66.             set castOffset to introFrames + 1
  67.             replaceBitmap(me)
  68.           else
  69.             if outroFrames = 0 then
  70.               if the castNum of sprite animChannel = (staticCastPos + 1) then
  71.                 set status to #done
  72.               else
  73.                 set the castNum of sprite animChannel to staticCastPos + 1
  74.                 exit
  75.               end if
  76.             else
  77.               set status to #outro
  78.               set castOffset to introFrames + 1
  79.               replaceBitmap(me)
  80.             end if
  81.           end if
  82.         else
  83.           set castOffset to castOffset + 1
  84.           replaceBitmap(me)
  85.         end if
  86.       else
  87.         if status = #outro then
  88.           processSound(me)
  89.           if castOffset = 0 then
  90.             set status to #done
  91.           else
  92.             if castOffset = (introFrames + 1) then
  93.               set castOffset to introFrames + mainFrames + 1
  94.             else
  95.               if castOffset = (introFrames + mainFrames + outroFrames) then
  96.                 set castOffset to 0
  97.               else
  98.                 set castOffset to castOffset + 1
  99.               end if
  100.             end if
  101.             replaceBitmap(me)
  102.           end if
  103.         else
  104.           if status = #done then
  105.             if soundStatus = #ROsoundOn then
  106.               repeat while soundBusy(1)
  107.               end repeat
  108.               if clicked then
  109.                 playClickSound(me)
  110.                 updateStage()
  111.               end if
  112.             end if
  113.             if clicked = 1 then
  114.               if soundWait and (soundStatus <> #clickSoundDone) then
  115.                 repeat while soundBusy(1)
  116.                 end repeat
  117.               end if
  118.               set clicked to 0
  119.               if soundWait then
  120.                 puppetSound(0)
  121.               end if
  122.               do(commandString)
  123.               if soundWait = 0 then
  124.                 repeat while soundBusy(1)
  125.                   if objectp(gCustomCursor) then
  126.                     update(gCustomCursor)
  127.                     updateStage()
  128.                   end if
  129.                 end repeat
  130.                 puppetSound(0)
  131.               end if
  132.             else
  133.               puppetSound(0)
  134.               showAllActors()
  135.             end if
  136.             reset(me)
  137.             if resetFlag then
  138.               resetBitmap(me)
  139.             end if
  140.             if objectp(gLoopGroupObject) then
  141.               waitOneFrame(gLoopGroupObject)
  142.             end if
  143.           end if
  144.         end if
  145.       end if
  146.     end if
  147.   end if
  148. end
  149.  
  150. on processSound me
  151.   if soundStatus = #off then
  152.     playClickSound(me)
  153.   else
  154.     if soundStatus = #ROsoundOn then
  155.       if not soundBusy(1) then
  156.         set soundStatus to #off
  157.       end if
  158.     else
  159.       if soundStatus = #clickSoundOn then
  160.         if not soundBusy(1) then
  161.           set soundStatus to #clickSoundDone
  162.         end if
  163.       end if
  164.     end if
  165.   end if
  166. end
  167.  
  168. on playClickSound me
  169.   if clicked and (clickSound <> EMPTY) then
  170.     puppetSound(clickSound)
  171.     set soundStatus to #clickSoundOn
  172.   end if
  173. end
  174.  
  175. on hideCustomCursor me
  176.   cursor(-1)
  177.   removeSprite(48)
  178. end
  179.  
  180. on click me
  181.   if (buttonChannel = the clickOn) and (clicked = 0) then
  182.     set clicked to 1
  183.   end if
  184. end
  185.  
  186. on replaceBitmap me
  187.   set the castNum of sprite animChannel to staticCastPos + castOffset
  188.   set resetFlag to 1
  189. end
  190.  
  191. on select me
  192.   set the castNum of sprite animChannel to staticCastPos - 1
  193.   set resetFlag to 0
  194. end
  195.  
  196. on reset me
  197.   set status to #static
  198.   set soundStatus to #off
  199.   set castOffset to 0
  200.   set gRollAnimButton to EMPTY
  201. end
  202.  
  203. on resetBitmap me
  204.   set the castNum of sprite animChannel to staticCastPos
  205. end
  206.  
  207. on makeButtonJump me
  208.   set jumpBase to staticCastPos + 6
  209.   repeat with offset = 0 to 8
  210.     set the castNum of sprite animChannel to jumpBase + offset
  211.     updateStage()
  212.     startTimer()
  213.     repeat while the timer < 3
  214.     end repeat
  215.   end repeat
  216.   removeSprite(animChannel)
  217.   updateStage()
  218. end
  219.